//
//  def_compound_statement.h
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#ifndef compilation_def_compound_statement_h
#define compilation_def_compound_statement_h

/*
 compound_statement
 : '{' '}' {printf("compound_statement\n");}
 | '{' statement_list '}' {printf("compound_statement\n");}
 | '{' declaration_list statement_list '}' {printf("compound_statement\n");}
 ; 
 */
struct def_compound_statement{
	void * parent;
	int type;
	struct def_statement_list * statement_list;
	struct def_declaration_list * declaration_list;
};

struct def_compound_statement * compound_statement_create(void * parent){
	struct def_compound_statement * s = malloc(sizeof(*s));
	s->type = 0;
	s->parent = parent;
	s->statement_list = NULL;
	s->declaration_list = NULL;
	return s;
}

void compound_statement_print(struct def_compound_statement * s){
	switch(s->type){
		case 1:
			printf("{ }");
			break;
		case 2:
			printf("{");
			statement_list_print(s->statement_list);
			printf("}");
			break;
		case 3:
			printf("{");
			declaration_list_print(s->declaration_list);
			statement_list_print(s->statement_list);printf("}");
			break;
	}
}
#endif
